//
//  YCLBaseTableViewController.swift
//  新浪微博01
//
//  Created by yaochunlin on 16/4/9.
//  Copyright © 2016年 yaochunlin. All rights reserved.
//

import UIKit

class YCLBaseTableViewController: UITableViewController {

//    //用户是否登录
    var userLogin = YCLUserAccountViewModel.sharedUserAccountViewModel.isLogin
    
    override func loadView() {
        
        userLogin ? super.loadView() : setupVisitorView()
        
    }
    
    private func setupVisitorView() {
        
        view = visitorView
        
        visitorView.delegate = self
        
        if self is YCLHomeViewController{
            
            visitorView.startRotation()
        }else if self is YCLMessageViewController{
        
            visitorView.setupVisitorInfo("visitordiscover_image_message", describeLabelText: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }else if self is YCLDiscoverViewController{
        
            visitorView.setupVisitorInfo("visitordiscover_image_message", describeLabelText: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }else if self is YCLProfileViewController{
        
            visitorView.setupVisitorInfo("visitordiscover_image_profile", describeLabelText: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        //设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("visitorViewDidClickRegisterBtn"))
        navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("visitorViewDidClickLoginBtn"))
        
    }
    
    

    //MARK 懒加载
    //访问视图
    private lazy var visitorView:YCLVisitorView = YCLVisitorView()
}

//MARK 扩展
extension YCLBaseTableViewController: YCLVisitorViewDelegate {

    //MARK YCLVisitorViewDelegate代理方法
    func visitorViewDidClickRegisterBtn(){
        
        YCLPrint("点击了注册按钮")
    }
    func visitorViewDidClickLoginBtn(){
        
        //modal出一个控制器
        let OauthVC = YCLOauthViewController()
        
        let navVC = UINavigationController.init(rootViewController: OauthVC)
        
        presentViewController(navVC, animated: true, completion: nil)
        
    }
    
}